<template>
  <div style="width: 800px;margin: 100px auto;">
    <h1>注册页面</h1>
    <el-form label-width="80px" >
      <el-form-item label="用户名"  >
        <el-input placeholder="请输入用户名" v-model="user.username"  ></el-input>
      </el-form-item>
      <el-form-item label="密码"  >
        <el-input type="password" placeholder="请输入密码" v-model="user.password"></el-input>
      </el-form-item>
      <el-form-item label="昵称" >
        <el-input placeholder="请输入昵称" v-model="user.nickname"  ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="reg()">注册</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
 data(){
   return{
     user:{}
   }
 },
  methods:{
    reg(){
      //
      let url= "http://localhost:8080/v1/users/reg"
      //console.log(this.user)
      this.axios.post(url,this.user).then((reponse)=>{
         // console.log(reponse)
        if(reponse.data.code == 1){
          this.$message.success('注册成功！！！')
          this.$router.push('/login')
        }else{
          this.$message.error(reponse.data.msg)
         
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
